﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public static class StringExtend
    {
        /// <summary>
        /// "a,b,c" 逗號分隔的
        /// </summary>
        /// <param name="prefix">前缀,拼接在每个List的字符串前</param>
        /// <returns></returns>
        public static List<string> ConvertToList(this string str, string prefix = "")
        {
            if (string.IsNullOrEmpty(str)) return new List<string>(0);
            var list = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            list = list.Select(s =>
              {
                  s = (prefix ?? "") + s;
                  return s;
              }).ToList();
            return list;
        }
    }
}
